﻿using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.Environment.Extensions;
using System;
using Orchard.Security;
using Orchard;
using Nwazet.Commerce.Models;

namespace Rework.CommerceHistory.Models {
    [OrchardFeature("Rework.CommerceHistory")]
    public class CommerceHistoryPart : ContentPart<CommerceHistoryPartRecord> {
        public int UserId { get { return Record.UserId; } set { Record.UserId = value; } }
        public int ProductId { get { return Record.ProductId; } set { Record.ProductId = value; } }
        public int Quantity { get { return Record.Quantity; } set { Record.Quantity = value; } }
        public double Price { get { return Record.Price; } set { Record.Price = value; } }
        public bool IsPaymentConfirmed { get { return Record.IsPaymentConfirmed; } set { Record.IsPaymentConfirmed = value; } }
        public string ConfirmedTransactionId { get { return Record.ConfirmedTransactionId; } set { Record.ConfirmedTransactionId = value; } }
        public string ConfirmedIPN { get { return Record.ConfirmedIPN; } set { Record.ConfirmedIPN = value; } }
        
        public IUser User {
            get { return this.ContentItem.ContentManager.Get<IUser>(UserId); }
        }

        public ProductPart Product {
            get { return this.ContentItem.ContentManager.Get<ProductPart>(ProductId); }
        }
    }
}
